<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="腾讯商品添加">
    <#if (goodsId)??>
        <#assign isEdit = true/>
    <#else>
        <#assign isAdd = true/>
    </#if>
<body class="input">

<script type="text/javascript">
    $().ready(function () {
        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#inputForm");
        var $tab = $("#tab");
        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });

        // 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                "tencent.productName":{
                    required:true
                },
                "tencent.in_acct_type":{
                    required:true
                },
                "tencent.sell_type":{
                    required:true
                },
                "tencent.in_acct_type":{
                    required:true
                },
                "tencent.sell_sub_type":{
                    required:true
                },
                "tencent.num":{
                    required:true
                },
                "tencent.inPrice":{
                    required:true
                }/*,
                "tencent.rechargeMode":{
                    required:true
                }*/

            },
            messages:{
                "tencent.productName":{
                    required:"产品名称不能为空！"
                },
                "tencent.in_acct_type":{
                    required:"用户帐号类型不能为空！"
                },
                "tencent.sell_type":{
                    required:"服务类型不能为空！"
                },
                "tencent.in_acct_type":{
                    required:"用户帐号类型不能为空！"
                },
                "tencent.sell_sub_type":{
                    required:"服务子类型不能为空！"
                },
                "tencent.num":{
                    required:"充值数量不能为空！"
                },
                "tencent.inPrice":{
                    required:"商品进价不能为空！"
                }/*,
                "tencent.rechargeMode":{
                    required:"充值方式不能为空！"
                }*/
            },
            submitHandler:function (form) {
                //$(form).find(":submit").attr("disabled", true);
                form.submit();
            }
        });
        
        $("#submitId").click(function () {
            var validatorPrice = check1();
            return  validatorPrice;
        });
    });
    function check1() {
        $("#priceSpan").html('');
        //var e = /^(([1-9]\d{0,5})|0)(\.\d{1,3})?$/;
        var ee = /^(([1-9]\d*)|\d)(\.\d{1,3})?$/;
        var blsx = $("#price").val();
        if (!ee.test(blsx)) {
            $("#priceSpan").html('价格格式不正确！(例：0.000)');
            return false;
        }
        else {
            return true;
        }
    }
</script>

<div class="body">
    <div class="inputBar">
        <h1><span class="icon">&nbsp;</span><#if isAdd??>腾讯商品添加<#else>编辑腾讯商品</#if></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form id="inputForm" class="validate" action="<#if isAdd??>${web_base}/game/tencent!save.htm<#else>${web_base}/game/tencent!edit.htm</#if>" method="post">
        <ul class="tab">
            <li>
                <input type="button" value="基本信息" hidefocus="true"/>
            </li>
        </ul>
        <table class="inputTable tabContent">
            <#if isEdit??>
                <tr>
                    <th>
                        原始产品编号:
                    </th>
                    <td>
                        <input type="text" name="tencent.goodsId" class="formText"
                               value="${(tencent.goodsId)!}" readonly="readonly"/>
                    </td>
                </tr>
            </#if>
            <tr>
                <th>
                    产品名称:
                </th>
                <td>
                    <#if isAdd??>
                        <input type="text" name="tencent.productName" class="formText {required: true}" value=""/>
                        <label class="requireField">*</label>
                    <#else>
                        <input type="text" name="tencent.productName" class="formText"
                               value="${(tencent.productName)!}" />
                    </#if>
                </td>
            </tr>
            <tr>
                <th>
                    用户帐号类型:
                </th>
                <td>
                    <#if isAdd??>
                        <input type="text" name="tencent.in_acct_type" class="formText {required: true}" value=""/>
                        <label class="requireField">*</label>
                    <#else>
                        <input type="text" name="tencent.in_acct_type" class="formText"
                               value="${(tencent.in_acct_type)!}"/>
                    </#if>
                </td>
            </tr>
            <tr>
                <th>
                    服务类型:
                </th>
                <td>
                    <#if isAdd??>
                        <input type="text" name="tencent.sell_type" class="formText {required: true}" value=""/>
                        <label class="requireField">*</label>
                    <#else>
                        <input type="text" name="tencent.sell_type" class="formText"
                               value="${(tencent.sell_type)!}" />
                    </#if>
                </td>
            </tr>
            <tr>
                <th>
                    服务子类型:
                </th>
                <td>
                    <#if isAdd??>
                        <input type="text" name="tencent.sell_sub_type" class="formText {required: true}" value=""/>
                        <label class="requireField">*</label>
                    <#else>
                        <input type="text" name="tencent.sell_sub_type" class="formText"
                               value="${(tencent.sell_sub_type)!}" />
                    </#if>
                </td>
            </tr>
            <tr>
                <th>
                    充值数量:
                </th>
                <td>
                    <#if isAdd??>
                        <input type="text" name="tencent.num" class="formText {required: true}" value=""/>
                        <label class="requireField">*</label>
                    <#else>
                        <input type="text" name="tencent.num" class="formText"
                               value="${(tencent.num)!}" />
                    </#if>
                </td>
            </tr>
            <#if isEdit??>
                <tr>
                    <th>
                        充值方式:
                    </th>
                    <td>
                        <select class="formText {required: true}" name="tencent.rechargeMode" >
                            <option value="">-请选择-</option>
                            <option value="1"
                                    <#if tencent.rechargeMode?? && tencent.rechargeMode =="1">selected="selected" </#if>>
                                卡充
                            </option>
                            <option value="2"
                                    <#if tencent.rechargeMode?? && tencent.rechargeMode =="2">selected="selected" </#if>>
                                直充
                            </option>
                        </select>
                    </td>
                </tr>
            </#if>
            <tr>
                <th>
                    进价(元):
                </th>
                <td>
                    <input type="text" id="price" name="tencent.inPrice" class="formText {required: true}"
                           onblur="check1()" value="${(tencent.inPrice)!}"/>
                    <label class="requireField">*</label>
                    <span id="priceSpan" style="color: red;"></span>
                </td>
            </tr>
            <#if isEdit??>
                <tr>
                    <th>
                        是否审核:
                    </th>
                    <td>
                        <select class="formText {required: true}" name="tencent.isAudit" disabled="disabled">
                            <option value="">-请选择-</option>
                            <option value="0"
                                    <#if tencent.rechargeMode?? && tencent.isAudit =="0">selected="selected" </#if>>未审核
                            </option>
                            <option value="1"
                                    <#if tencent.rechargeMode?? && tencent.isAudit =="1">selected="selected" </#if>>已审核
                            </option>
                        </select>
                    </td>
                </tr>
            </#if>
            <tr>
                <th>
                    说明:
                </th>
                <td>
                    <#if isAdd??>
                        <textarea class="formTextarea" name="tencent.memo"></textarea>
                    <#else>
                        <textarea class="formTextarea" name="tencent.memo"> ${(tencent.memo)!}</textarea>
                    </#if>
                </td>
            </tr>
        </table>
        <div class="buttonArea">
            <input type="submit" id="submitId" class="formButton" <#if isAdd??>value="添  加" <#else>value="更  新" </#if>hidefocus="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回"
                   hidefocus="true"/>
        </div>
    </form>
</div>
</body>
</@edit>
